﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DapperEx;
using Dapper;
using System.Collections;
using System.Data;
using System.Collections.Generic;
using System.Diagnostics;

namespace DapperExTest.Sdf数据库
{
    [TestClass]
    public class UnitTest1
    {
        public string conn_Test = "strSqlCe_DbTest";

        [TestMethod]
        public void TestInsertBatch()
        {
            Func<long> func = new Func<long>(() =>
            {
                return new DbBase(conn_Test).Count<TrunAroundJournal>();
            });

            long count = func();
            if (count > 1000000)
            {
                return;
            }
            List<TrunAroundJournal> list = new List<TrunAroundJournal>();
            for (int i = 0; i < 1000000; i++)
            {
                TrunAroundJournal model = new TrunAroundJournal()
                {
                    Barcode = "Barcode" + i,
                    Createtime = DateTime.Now,
                    CreateUserID = i,
                    ItemCategoryID = i + 100,
                    Price = i * 1.1M
                };
                list.Add(model);
            }

            bool ret = new DbBase(conn_Test).InsertBatch<TrunAroundJournal>(list);
            if (ret)
            {
                Debug.WriteLine("----成功条数--：" + func());
            }
        }
        [TestMethod]
        public void TestQuery()
        {
            TrunAroundJournal model = new DbBase(conn_Test).SingleOrDefault<TrunAroundJournal>();
        }
    }
}
